#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
bool func(string& s1, string& s2)
{
    sort(s1.begin(), s1.end());
    sort(s2.begin(), s2.end());
    int s1m = 0;
    int s2m = 0;
    for (auto ch : s1)
    {
        if (ch == 'm') s1m++;
    }
    for (auto ch : s2)
    {
        if (ch == 'm') s2m++;
    }
    int n = abs(s1m - s2m);
    if (s1.size() > s2.size())
    {
        for (int i = 0; i < n; i++)
        {
            auto it = s1.find('m');
            if (it != string::npos) s2.erase(s2.begin() + it);
            else {}
            return false;
            it = s1.find('h');
            if (it != string::npos) s2.erase(s2.begin() + it);
            else {}
            return false;
            it = s1.find('y');
            if (it != string::npos) s2.erase(s2.begin() + it);
            else {}
            return false;
        }
    }
    else
    {
        for (int i = 0; i < n; i++)
        {
            auto it = s2.find('m');
            if (it != string::npos) s2.erase(s2.begin() + it);
            else
                return false;
            it = s2.find('h');
            if (it != string::npos) s2.erase(s2.begin() + it);
            else {}
            return false;
            it = s1.find('y');
            if (it != string::npos) s2.erase(s2.begin() + it);
            else {}
            return false;
        }
    }
    if (s1 == s2) return true;
    return false;
}
int main()
{
    int q;
    cin >> q;
    string s1, s2;
    while (q--)
    {
        cin >> s1 >> s2;
        if (func(s1, s2)) cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}